package com.easyCms.wechat.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.easyCms.base.common.CodeConst;
import com.easyCms.wechat.dao.WechatUserDAO;
import com.easyCms.wechat.entity.WechatUser;

import java.util.List;

@Service
public class WechatUserSV {
	@Autowired
	private WechatUserDAO wechatUserDAO;

	public WechatUser findValidByOpenId(String openId) {
		return wechatUserDAO.findByOpenIdAndState(openId, CodeConst.State.STATE_VALID);
	}

	public WechatUser save(WechatUser wechatUser) {
		return wechatUserDAO.save(wechatUser);
	}

	public WechatUser findValidById(Long id) {
		return wechatUserDAO.findByIdAndState(id, CodeConst.State.STATE_VALID);
	}

	public List<WechatUser> findByClassId(String classId) {
		return wechatUserDAO.findByClassId(classId);
	}
}
